package com.yueshixinxi.test1.Notification;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Notification;
import android.app.PendingIntent;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;

import com.yueshixinxi.test1.R;

public class NotificationActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_notification);
        initNormalNotification();

    }

    private void initNormalNotification() {
        Notification.Builder builder=new Notification.Builder(this);
        Intent mIntent=new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.baidu.com"));
        PendingIntent pendingIntent=PendingIntent.getActivities(this,0, new Intent[]{mIntent},0);

        builder.setContentIntent(pendingIntent);
        builder.setSmallIcon(R.drawable.ic_launcher_background);
        builder.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher_background));
        builder.setAutoCancel(true);
        builder.setContentTitle("普通通知");
    }
}